// Created 3/30/09	
// Author: Dustin McBeth

// Purpose: To write code for #2 with out confirming it works on the bot
// 	        - No really go figure!

// Steps:
// - Activated Port F (ADC Alternating to Digital Controller)
// - Set pins
// - write code to do stuff with those pins
// - Watch bot do nothing because there was no testing with a working prototype


// Use: 
// - Initilize Movement with Movement_init();
// - Then just call the function you need based on the name
// - Then call Movement_Stop(); to stop

// 1 out 0 in

// Define macro to get the value of each bit
#define GET_BIT(port) (*(volatile bit_field *) (_SFR_ADDR(port)))

#define Move_Pin_0 GET_BIT(PORTF).bit0
#define Move_Pin_1 GET_BIT(PORTF).bit1
#define Move_Pin_2 GET_BIT(PORTF).bit2
#define Move_Pin_3 GET_BIT(PORTF).bit3
#define Move_Pin_4 GET_BIT(PORTF).bit4
#define Move_Pin_5 GET_BIT(PORTF).bit5
#define Move_Pin_6 GET_BIT(PORTF).bit6
#define Move_Pin_7 GET_BIT(PORTF).bit7


void Movement_init(void) {
	PORTB=0x00;
	DDRB=0b10101010;   // odds are out - Even are ins

}

void Move_Stop (void) {
	// pin 6,
	Move_Pin_0 = 0;
	Move_Pin_2 = 0;
	Move_Pin_4 = 0;
	Move_Pin_6 = 0;
	
}

void Move_Forward (void) {
	// pin 6, 4, 2, 0 turn on = 1
	Move_Pin_0 = 1;
	Move_Pin_2 = 1;
	Move_Pin_4 = 1;
	Move_Pin_6 = 1;
	
}

void Move_Left (void) {
	// pin 6, 4, 2, 0 turn on = 1
	Move_Pin_0 = 1;
	Move_Pin_2 = 1;
	Move_Pin_4 = 0.5;
	Move_Pin_6 = 0.5;
	
}

void Move_Right (void) {
	// pin 6, 4, 2, 0 turn on = 1
	Move_Pin_0 = 0.5;
	Move_Pin_2 = 0.5;
	Move_Pin_4 = 1;
	Move_Pin_6 = 1;
	
}

void Move_Backwards (void) {
	// pin 6, 4, 2, 0 turn on = 1
	Move_Pin_0 = -1;
	Move_Pin_2 = -1;
	Move_Pin_4 = -1;
	Move_Pin_6 = -1;
	
}
